Skip to content

Switch from got to ky + fetch in notion-client#394

Merged
transitive-bullshit merged 2 commits into
masterfrom
feature/support-fetch-and-edge-runtimes
Oct 31, 2024
Merged

Switch from got to ky + fetch in notion-client#394
transitive-bullshit merged 2 commits into
masterfrom
feature/support-fetch-and-edge-runtimes

Conversation

@transitive-bullshit
Copy link
Copy Markdown
Member

This PR removes got in favor of ky in notion-client. This means that notion-client is no longer tied to Node.js.

ky is a thin wrapper around fetch, which makes notion-client compatible with edge runtimes such as Cloudflare Workers, Vercel edge functions, and Deno.

It also adds a secondary entrypoint to notion-client which will only be used by "browsers" (and this should include edge runtimes, though this hasn't been tested yet in practice).

The node.js entrypoint bundles ky-universal, which polyfills node-fetch and abort-controller for node.js so that ky works in node.js the same as any other fetch-supported environment.

The main advantage of using ky instead of fetch directly is that ky includes robustness features such as automatic HTTP status code-aware retrying.

The main downside of this change is that got is more robust on node.js than any other fetch-based HTTP client that I'm aware of, including ky (though ky is the best fetch-based HTTP client that I'm aware of).

See @remorses previous PR which started this work in #312 and related discussion in #160

cc @pbteja1998 @MartinXPN @on2air

@transitive-bullshit transitive-bullshit added the enhancement New feature or request label Oct 17, 2022
@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
react-notion-x ❌ Failed (Inspect) Oct 31, 2024 2:30am
react-notion-x-minimal-demo ❌ Failed (Inspect) Oct 31, 2024 2:30am

@pbteja1998
Copy link
Copy Markdown
Contributor

This is awesome. Thanks for this. I will be happy to test it out on Cloudflare Workers once it's live.

Copy link
Copy Markdown
Collaborator

@normdoow normdoow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! This is really cool.

@nijamaDev
Copy link
Copy Markdown

Hi, I wanted to know if there was any reason this PR isn't merge yet?

@lhojun
Copy link
Copy Markdown

lhojun commented Nov 8, 2023

is there any reasons that PR isn't merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants